/**
 * 
 */
package cn.edu.bjtu.entity.impl;

import org.apache.log4j.Logger;

import cn.edu.bjtu.entity.Command;
import cn.edu.bjtu.entity.ExecuteContext;
import cn.edu.bjtu.entity.ExecuteResult;

/**
 * 只是启动context
 * @author alex
 *
 */
public class GeneralCommand implements Command{
	protected Logger LOG;
	/**
	 * 
	 */
	public GeneralCommand() {
		LOG = Logger.getLogger(GeneralCommand.class);
	}
	@Override
	public ExecuteResult<?> execute(ExecuteContext ctx) {
		try{
			if(ctx instanceof BaseSimpleContext){
				BaseSimpleContext bsc =  (BaseSimpleContext) ctx;
				String url = bsc.getHostname() + " \t " + bsc.getURI();
				LOG.info(url);
			}
			ctx.fire();
			if(ctx instanceof ExecuteResult){
				return (ExecuteResult) ctx;
			}else{
				return new SuccessExecuteResult(ctx,"Success execute");
			}			
		}catch(Exception e){
			return new FailedExecuteResult(e.getMessage());
		}

	}

}
